<?php

   @include_once("../php/connect.php");
   if(!(isset($_POST["index"]) )){
        $obj = array();
        $obj["status"] = false;
        $obj["msg"] = "请传入参数";
        $json = json_encode($obj);
        exit($json);
    }
 
    $orderCol="price";
    $orderType="desc";
    $showNum=20;
    $pageIndex=$_POST["index"];
    $selectAll="select count(*) as count from  `goodlist1`";
    $resultAll = mysqli_query($conn,$selectAll);
$obj = array();

if($resultAll){
      $item= mysqli_fetch_assoc($resultAll);
        $count=$item["count"];
        $maxpage=ceil($count/$showNum);   //向上取整  得到多少页

       if($pageIndex>$maxpage)$pageIndex=$maxpage;  
       if($pageIndex<1)$pageIndex=1;
       $skipNum= ($pageIndex-1)*$showNum;
        $sql="select title,gid,imgid,price,jieshao from `goodlist1`  limit $skipNum, $showNum";
        $result=mysqli_query($conn,$sql);

        $obj=array();
        if($result){
            $list=array();
            while($item=mysqli_fetch_assoc($result)){
                $item["gid"]=$item["gid"];
                $item["title"]=$item["title"];
                $item["imgid"]=$item["imgid"];
                $item["price"]=$item["price"];
                $item["jieshao"]=$item["jieshao"];
               array_push($list,$item); 
            }$obj["status"] = true;
             $obj["msg"] = "OK";
             $obj["list"] = $list;
             $obj["maxpage"]=$maxpage;
     }

} else{
 $obj['status']=false;
}


        
        echo json_encode($obj);



?>